package com.liuguangzhou.controller;

import com.liuguangzhou.pojo.User;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

/**
 * @ClassName HelloController
 * @Description: TODO
 * @Author liuguangzhou
 * @Date 2020/3/27
 * @Version V1.0
 **/

//注解的用法 https://blog.csdn.net/xiaojin21cen/article/details/78654652
@Api(tags = "helloController控制器")
@RestController
public class HelloController {
    @RequestMapping(value = "hello")
    public String hello() {
        return "hello";
    }


//    @RequestMapping(value = "getUser")
//    public User getUser(){
//        return new User();
//    }


    @ApiOperation(value = "返回user", notes = "需要传入用户名 密码 会返回User对象")
    @GetMapping(value = "getUser")
    public User getUser(User user) {
        return user;
    }


    @ApiOperation(value = "登录", notes = "登录方法")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "mobile", value = "手机号", required = true, paramType = "form", dataType = "String"),
            @ApiImplicitParam(name = "userName", value = "用户名", required = true, paramType = "query", dataType = "String"),
            @ApiImplicitParam(name = "password", value = "密码", required = true, paramType = "query", dataType = "String")
    }
    )
    @PostMapping(value = "login")
    public User login(String mobile, User user) {
        System.out.println(mobile);
        return user;
    }


//seagger 中这个form取不到值 今后在研究
    @ApiOperation(value="用户登录",notes="随边说点啥")
    @ApiImplicitParams({
            @ApiImplicitParam(name="mobile",value="手机号",required=true,paramType="form"),
            @ApiImplicitParam(name="password",value="密码",required=true,paramType="form"),
            @ApiImplicitParam(name="age",value="年龄",required=true,paramType="form")
    })
    @PostMapping("/login1")
    public void login1(String mobile, String password,
                            Integer age){

        System.out.println(mobile);
        System.out.println(password);
        System.out.println(age);
    }
}
